package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductCateService;
import com.mall.shopping.dto.AllProductCateRequest;
import com.mall.shopping.dto.AllProductCateResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CategoriesController {
    @Reference(interfaceClass = IProductCateService.class, check = false)
    IProductCateService iProductCateService;

    @GetMapping("shopping/categories")
    @Anoymous
    public ResponseData categories(AllProductCateRequest allProductCateRequest) {
        // 设定排序规则
        allProductCateRequest.setSort("sortOrder");
        AllProductCateResponse allProductCateResponse = iProductCateService.getAllProductCate(allProductCateRequest);

        ResponseUtil<List> responseUtil = new ResponseUtil<>();
        responseUtil.setData(allProductCateResponse.getProductCateDtoList());
        return responseUtil.setData(allProductCateResponse.getProductCateDtoList());

    }
}
